using System;
using System.Collections.Generic;
using System.Text;
using DAO;
using DTO;
using System.Data;
namespace BUS
{
    public enum LyDoThanhLyBUSResult
    {
        OK ,
        DAOERROR
    }
    public class LyDoThanhLy
    {
        public static LyDoThanhLyBUSResult SelectAll(List<DTO.LyDoThanhLy> danhSach)
        {
            string sql = "select * from LyDoThanhLy";
            DAO.Interface dao = new DAO.LyDoThanhLy();
            DataTable dt = dao.Select(sql);
            if(dt!= null)
            {
                for(int i=0;i<dt.Rows.Count;i++)
                {
                    DTO.LyDoThanhLy dto = new DTO.LyDoThanhLy();
                    dto.MaLyDo = int.Parse(dt.Rows[i].ItemArray[0].ToString());
                    dto.TenLyDo = dt.Rows[i].ItemArray[1].ToString();
                    danhSach.Add(dto);
                }
                return LyDoThanhLyBUSResult.OK;
            }
            return LyDoThanhLyBUSResult.DAOERROR;
        }
    }
}
